package com.cskaoyan.factory;

import com.cskaoyan.bean.Animal;
import com.cskaoyan.bean.Cat;
import com.cskaoyan.bean.Dog;
import com.cskaoyan.bean.Pig;

/**
 * 简单工厂
 * @author stone
 * @date 2021/11/16 15:06
 */
public class AnimalFactory {

    public Animal create(String name) {
        if ("cat".equals(name)) {
            return new Cat();
        } else if ("dog".equals(name)) {
            return new Dog();
        } else if ("pig".equals(name)) {
            return new Pig();
        }
        return null;
    }
}
